﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Newtonsoft.Json;

namespace StevensReceipts.Domain
{
    public class Receipt : ITransaction
    {
        [Key]
        public int Id { get; set; }

        public int ContactId { get; set; }

        [Required]
        [ForeignKey("ContactId")]
        [JsonIgnore]
        public virtual Contact TransactionContact { get; set; }

        [DataType(DataType.Date)]
        [Required]
        public DateTime TransactionDate { get; set; }

        [DataType(DataType.Date)]
        public DateTime? DueDate { get; set; }

        [DataType(DataType.Currency)]
        [Required]
        public double Total { get; set; }

        public int? ChartofAccountId { get; set; }

        [JsonIgnore]
        [ForeignKey("ChartofAccountId")]
        public virtual ChartofAccount ChartofAccount { get; set; }

        public string Note { get; set; }


        public DateTime? Created { get; set; }

        public DateTime? Modified { get; set; }
    
        [MaxLength(20)]
        public string Reference { get; set; }

        public bool IncludeTax { get; set; }

        public bool IsTaxInclusive { get; set; }

        [JsonIgnore]
        public virtual ICollection<ReceiptItem> Items { get; set; }

        public Receipt()
        {
            TransactionDate = DateTime.Now;
            Created = DateTime.Now;
            IncludeTax = true;
            IsTaxInclusive = true;
        }

    }
}